package com.kejiguan.ui.response;

import com.google.gson.annotations.Expose;
import com.google.gson.internal.Streams;
import com.kejiguan.ui.model.ExhibitionRunItem;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * Created by YYY on 2016/4/28.
 */
public class NeItemRunDataResponse extends BaseResponse {

    private String displayId;

    private String displayName;

    @Expose
    private Map<String, List<ExhibitionRunItem>> equipStatusRecordMap;

    private List<ExhibitionRunItem> neItemRunItems;

    public Map<String, List<ExhibitionRunItem>> getEquipStatusRecordMap() {
        return equipStatusRecordMap;
    }

    public void setEquipStatusRecordMap(Map<String, List<ExhibitionRunItem>> equipStatusRecordMap) {
        this.equipStatusRecordMap = equipStatusRecordMap;
    }

    public String getDisplayId() {
        return displayId;
    }

    public void setDisplayId(String displayId) {
        this.displayId = displayId;
    }

    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }

    public List<ExhibitionRunItem> getNeItemRunItems() {
        return neItemRunItems;
    }

    public void setNeItemRunItems(List<ExhibitionRunItem> neItemRunItems) {
        this.neItemRunItems = neItemRunItems;
    }

    public void rebuidDatas() {

        neItemRunItems=new ArrayList<>();

        if (null != equipStatusRecordMap) {

            Set<String> keys=equipStatusRecordMap.keySet();
            Iterator<String> haha=keys.iterator();
            while (haha.hasNext())
            {
                String key=haha.next();
                List<ExhibitionRunItem> subNeItemRunItems = equipStatusRecordMap.get(key);
                if (null!=subNeItemRunItems)
                {
                    neItemRunItems.addAll(subNeItemRunItems);
                }

            }

//            for(int i=0;i<neItemRunItems.size();i++)
//            {
//                ExhibitionRunItem item=neItemRunItems.get(i);
//                if (item.getEquipId().equals("点赞机1"))
//                {
//                    neItemRunItems.remove(item);
//                    break;
//                }
//            }
//            Collections.sort(neItemRunItems);

            for(int i=0;i<neItemRunItems.size();i++)
            {
                ExhibitionRunItem item=neItemRunItems.get(i);
                if (item.getCurrent()==0&&!item.getEquipId().equals("三维滚环"))
                {
                    item.setCurrent(0);
                    item.setTemperature(0);
                    item.setVoltage(0);
                }
            }

        }
    }


}
